package com.acwing.partition46;

import java.io.*;

/**
 * @author rkc
 * @date 2022/7/24 9:53
 */
public class AC4520质数 {

    private static StreamTokenizer tokenizer = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    private static PrintWriter writer = new PrintWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        int k = nextInt();
        while (k-- > 0) {
            int x = nextInt();
            for (int i = 1; i <= 100; i++) {
                int y = Integer.parseInt(String.valueOf(x) + i);
                if (check(y)) {
                    writer.println(y);
                    break;
                }
            }
        }
        writer.flush();
    }

    private static boolean check(int x) {
        if (x < 2) return false;
        for (int i = 2; i <= x / i; i++) {
            if (x % i == 0) return false;
        }
        return true;
    }

    private static int nextInt() throws IOException {
        tokenizer.nextToken();
        return (int) tokenizer.nval;
    }
}
